﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace InfoWykaz
{
    public partial class PicDate : Form
    {
        public PicDate(String s)
        {
            InitializeComponent();
            this.dateTimePicker1.Value = DateTime.Now;
            this.Text = s;
        }

        public string date;
        public bool piced = false;

        private void button1_Click(object sender, EventArgs e)
        {
            this.piced = true;
            DateTime dt = this.dateTimePicker1.Value; 
            this.date = string.Format("{0}-{1}-{2} 00:00", 
                dt.Year, 
                this.fitIntByString(dt.Month, "0", 2, 1),
                this.fitIntByString(dt.Day, "0", 2, 1));
            this.Close();
        }

        public string fitIntByString(int x, string s, int les, int count)
        {
            string result = x.ToString();
            if (x.ToString().Length < les)
                for (int i = 0; i < count; i++) result = string.Format("{0}{1}", s, result);
            return result;
        }

        private void PicDate_Load(object sender, EventArgs e)
        {

        }
    }
}
